package top.songxs.gmall.payment.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.songxs.gmall.payment.properties.AlipayProperties;

@Configuration
public class AliPayConfiguration {
    @Autowired
    private AlipayProperties alipayProperties;
    @Bean
    public AlipayClient alipayClient(){
        //获得初始化的AlipayClient
        AlipayClient alipayClient = new DefaultAlipayClient(
                alipayProperties.getServerUrl(),
                alipayProperties.getAppId(),
                alipayProperties.getPrivateKey(),
                alipayProperties.getFormat(),
                alipayProperties.getCharSet(),
                alipayProperties.getPublicKey(),
                alipayProperties.getSignType());

        //设置请求参数
        return alipayClient;
    }






}
